package com.gw.detail.controllor.detail;

import java.util.List;

import com.gw.detail.domain.Mpers;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.gw.detail.service.IMpersService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 碰撞人员的数据Controller
 * 
 * @author WangBin
 * @date 2021-04-30
 */
@RestController
@RequestMapping("/detail/mpers")
public class MpersController extends BaseController
{
    @Autowired
    private IMpersService mpersService;

    /**
     * 查询碰撞人员的数据列表
     */
    @PreAuthorize("@ss.hasPermi('detail:mpers:list')")
    @GetMapping("/list")
    public TableDataInfo list(Mpers mpers)
    {
        startPage();
        List<Mpers> list = mpersService.selectMpersList(mpers);
        return getDataTable(list);
    }

    /**
     * 导出碰撞人员的数据列表
     */
    @PreAuthorize("@ss.hasPermi('detail:mpers:export')")
    @Log(title = "碰撞人员的数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Mpers mpers)
    {
        List<Mpers> list = mpersService.selectMpersList(mpers);
        ExcelUtil<Mpers> util = new ExcelUtil<Mpers>(Mpers.class);
        return util.exportExcel(list, "碰撞人员的数据数据");
    }

    /**
     * 获取碰撞人员的数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('detail:mpers:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mpersService.selectMpersById(id));
    }

    /**
     * 新增碰撞人员的数据
     */
    @PreAuthorize("@ss.hasPermi('detail:mpers:add')")
    @Log(title = "碰撞人员的数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Mpers mpers)
    {
        return toAjax(mpersService.insertMpers(mpers));
    }

    /**
     * 修改碰撞人员的数据
     */
    @PreAuthorize("@ss.hasPermi('detail:mpers:edit')")
    @Log(title = "碰撞人员的数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Mpers mpers)
    {
        return toAjax(mpersService.updateMpers(mpers));
    }

    /**
     * 删除碰撞人员的数据
     */
    @PreAuthorize("@ss.hasPermi('detail:mpers:remove')")
    @Log(title = "碰撞人员的数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mpersService.deleteMpersByIds(ids));
    }
}
